﻿using System.Collections.Generic;
using System.Linq;
using Risk.Services;

namespace Site.Models
{
    /// <summary>
    /// Data transfer object for an army
    /// </summary>
    public class ArmyDTO
    {
        public ArmyDTO(int armyId)
        {
            Id = armyId;
        }

        public int Id { get; set; }
        /// <summary>
        /// The owner of the army
        /// </summary>
        public PlayerDTO Player { get { return new PlayerDTO (DatabaseManager.GetPlayerId(Id)); } }

        /// <summary>
        /// The troops in this army
        /// </summary>
        public List<TroopDTO> Troops { get { return DatabaseManager.GetTroopIds(Id).Select(troopId => new TroopDTO(troopId)).ToList(); } }

        /// <summary>
        /// The number of troops that are not stationed
        /// </summary>
        public int Reserve { get { return DatabaseManager.GetArmyReserve(Id); } set { DatabaseManager.SetArmyReserve(value, Id); } }

        /// <summary>
        /// The number of troops that this army grows each turn
        /// </summary>
        public int Bonus { get { return DatabaseManager.GetArmyBonus(Id); } set { DatabaseManager.SetArmyBonus(value, Id); } }
    }
}